package org.summerframework.component.note.inform.controller;

import org.summerframework.component.note.inform.service.NoteInformRecordService;
import org.summerframework.component.note.inform.service.dto.NoteInformRecordDTO;
import org.summerframework.component.note.inform.service.dto.NoteInformRecordQueryDTO;
import org.summerframework.component.security.annotion.RoleRequired;
import org.summerframework.component.security.controller.BaseController;
import org.summerframework.core.base.result.ResultDTO;
import org.summerframework.core.page.PageResult;
import org.summerframework.core.util.OptionalUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;

@RoleRequired
@RestController
@Api(tags = "短信通知记录", description= "功能描述")
@RequestMapping("noteInformRecord")
public class NoteInformRecordController extends BaseController {
    @Resource
    private NoteInformRecordService noteInformRecordService;

    @PostMapping
    @ApiOperation("添加")
    public ResultDTO<Boolean> insert(NoteInformRecordDTO noteInformRecordDTO) {
        return ResultDTO.ok(true, noteInformRecordService.insert(noteInformRecordDTO));
    }

    @PutMapping
    @ApiOperation("更新")
    @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "", required = true, dataType = "Long", paramType = "query")})
    public ResultDTO<Integer> updateById(NoteInformRecordDTO noteInformRecordDTO) {
        return ResultDTO.ok(noteInformRecordService.updateById(noteInformRecordDTO));
    }

    @DeleteMapping("{id}")
    @ApiOperation("根据id删除")
    @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "", required = true, dataType = "Long", paramType = "path")})
    public ResultDTO<Integer> deleteById(@PathVariable("id") Long id) {
        return ResultDTO.ok(noteInformRecordService.deleteById(id));
    }

    @DeleteMapping
    @ApiOperation("根据id列表删除删除")
    @ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "根据ids删除", required = true, dataType = "List", paramType = "query")})
    public ResultDTO<Integer> deleteByIds(@RequestParam("ids") List<Long> ids) {
        return ResultDTO.ok(noteInformRecordService.deleteByIds(ids));
    }

    @GetMapping("{id}")
    @ApiOperation("根据id查询")
    @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "", required = true, dataType = "Long", paramType = "path")})
    public ResultDTO<NoteInformRecordDTO> selectById(@PathVariable("id") Long id) {
        return ResultDTO.ok(OptionalUtils.get(noteInformRecordService.selectById(id)));
    }

    @GetMapping
    @ApiOperation("根据query查询")
    public PageResult<NoteInformRecordDTO> selectPageResultByQuery(NoteInformRecordQueryDTO noteInformRecordQueryDTO) {
        return noteInformRecordService.selectPageResultByQuery(noteInformRecordQueryDTO);
    }
}
